<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('login', 'LoginController@showLoginForm')->name('admin.login');
Route::post('login', 'LoginController@login');
Route::get('logout', 'LoginController@logout');
Route::post('logout', 'LoginController@logout');

//Route::get('/', 'IndexController@index');


Route::get('index', ['as' => 'admin.index', 'uses' => function () {
    return redirect('/admin/setting/welcome');
}]);


//Route::get('product.index', ['as' => 'admin.product.index', 'uses' => function () {
//    return redirect('/admin/product');
//}]);

Route::group(['middleware' => ['auth:admin', 'menu', 'authAdmin']], function () {

    //------------------------------------权限管理-------------------------------------------------------//

    Route::get('permission/{cid}/create', ['as' => 'admin.permission.create', 'uses' => 'PermissionController@create']);
    Route::get('permission/manage', ['as' => 'admin.permission.manage', 'uses' => 'PermissionController@index']);
    Route::get('permission/{cid?}', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']);
    Route::post('permission/index', ['as' => 'admin.permission.index', 'uses' => 'PermissionController@index']); //查询
    Route::resource('permission', 'PermissionController', ['names' => ['update' => 'admin.permission.edit', 'store' => 'admin.permission.create']]);


    //------------------------------------角色管理---------------------------------------------------//

    Route::get('role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::post('role/index', ['as' => 'admin.role.index', 'uses' => 'RoleController@index']);
    Route::resource('role', 'RoleController', ['names' => ['update' => 'admin.role.edit', 'store' => 'admin.role.create']]);


    //------------------------------------用户管理-----------------------------------------------//

    Route::get('user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);  //用户管理
    Route::post('user/index', ['as' => 'admin.user.index', 'uses' => 'UserController@index']);
    Route::resource('user', 'UserController', ['names' => ['update' => 'admin.role.edit', 'store' => 'admin.role.create']]);



    //-------------------------------------产品--------------------------------------------------//
         // 产品模块
        Route::get('product', ['as' => 'admin.product', 'uses' => 'ProductController@index']);
        // 产品列表(展示页)
        Route::get('product/index', ['as' => 'admin.product.index', 'uses' => 'ProductController@index']);
        // 产品详情展示页
        Route::get('product/show/{id}', ['as' => 'admin.product.show', 'uses' => 'ProductController@show']);
        // 新建产品审核
        Route::any('product/create', ['as' => 'admin.product.create', 'uses' => 'ProductController@create']);
        // 修改产品详情审核
        Route::any('product/edit/{id}', ['as' => 'admin.product.edit', 'uses' => 'ProductController@edit']);
        // 产品上线
        Route::get('product/online/{id}', ['as' => 'admin.product.online', 'uses' => 'ProductController@online']);
        // 产品下线
        Route::get('product/offline/{id}', ['as' => 'admin.product.offline', 'uses' => 'ProductController@offline']);



    //-------------------------------------广告--------------------------------------------------//
    // 产品模块
    Route::get('ad', ['as' => 'admin.ad', 'uses' => 'AdController@index']);
    // 产品列表(展示页)
    Route::get('ad/index', ['as' => 'admin.ad.index', 'uses' => 'AdController@index']);
    // 产品详情展示页
    Route::get('ad/show/{id}', ['as' => 'admin.ad.show', 'uses' => 'AdController@show']);
    // 新建产品审核
    Route::any('ad/create', ['as' => 'admin.ad.create', 'uses' => 'AdController@create']);
    // 修改产品详情审核
    Route::any('ad/edit/{id}', ['as' => 'admin.ad.edit', 'uses' => 'AdController@edit']);
    // 产品上线
    Route::get('ad/online/{id}', ['as' => 'admin.ad.online', 'uses' => 'AdController@online']);
    // 产品下线
    Route::get('ad/offline/{id}', ['as' => 'admin.ad.offline', 'uses' => 'AdController@offline']);

    //-------------------------------------点击数统计--------------------------------------------------//
    // 统计模块
    Route::get('data/product', ['as' => 'admin.data.product', 'uses' => 'DataProductController@index']);
    // 产品列表(展示页)
    Route::get('data/product/index', ['as' => 'admin.data.product.index', 'uses' => 'DataProductController@index']);
    // 昨日的详情
    Route::get('data/product/index', ['as' => 'admin.data.product.index', 'uses' => 'DataProductController@index']);
    Route::get('data/product/lists/{id}', ['as' => 'admin.data.product.lists', 'uses' => 'DataProductController@list']);



    //-------------------------------------用户数统计--------------------------------------------------//
    // 统计模块
    Route::get('data/user', ['as' => 'admin.data.user', 'uses' => 'DataUserController@index']);
    // 产品列表(展示页)
    Route::get('data/user/index', ['as' => 'admin.data.user.index', 'uses' => 'DataUserController@index']);
    // 昨日的详情
    Route::get('data/user/lists/{id}', ['as' => 'admin.data.user.lists', 'uses' => 'DataUserController@list']);
    //excel导出
    Route::get('data/user/excel', ['as' => 'admin.data.user.excel', 'uses' => 'DataUserController@excel']);


    //--------------------------------------设置管理----------------------------------------------------//


    // 默认欢迎页面
    Route::any('setting/welcome', ['as' => 'admin.setting.welcome', 'uses' => 'SettingController@welcome']);



});

Route::get('/', function () {
    return redirect('/admin/index');
});

